﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using LCTMoodle.Models.ViewModels;
using LCTMoodle.Service;

using System.IO;

namespace LCTMoodle.Models.ViewModels
{
    public class KhoaHoc_ThanhVienViewModel : Model
    {
        public int maKhoaHoc { get; set; }
        public int maThanhVien { get; set; }
        public string tenThanhVien { get; set; }
        /// <summary>
        /// 0 nếu đang xin tham gia
        /// </summary>
        public int maThanhVienMoi { get; set; }
        public string tenThanhVienMoi { get; set; }
        /// <summary>
        /// MinValue nếu bị chặn
        /// </summary>
        public DateTime thoiDiemThamGia { get; set; }
        public DateTime thoiDiemBaiGiang { get; set; }
        public int soBaiMoiBaiGiang { get; set; }
        public DateTime thoiDiemTaiLieu { get; set; }
        public int soBaiMoiTaiLieu { get; set; }
        public DateTime thoiDiemBaiTap { get; set; }
        public int soBaiMoiBaiTap { get; set; }
        public DateTime thoiDiemDienDan { get; set; }
        public int soBaiMoiDienDan { get; set; }

        public override void assignModel(SqlDataReader dr)
        {
            for (int i = 0; i < dr.FieldCount; i++)
            {
                switch (dr.GetName(i))
                {
                    case "MaKhoaHoc":
                        maKhoaHoc = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    case "MaThanhVien":
                        maThanhVien = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    case "TenThanhVien":
                        tenThanhVien = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    case "MaThanhVienMoi":
                        maThanhVienMoi = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    case "TenThanhVienMoi":
                        tenThanhVienMoi = (dr.IsDBNull(i)) ? null : dr.GetString(i); break;
                    case "ThoiDiemThamGia":
                        this.thoiDiemThamGia = (dr.IsDBNull(i)) ? DateTime.MinValue : dr.GetDateTime(i); break;
                    case "ThoiDiemBaiGiang":
                        this.thoiDiemBaiGiang = (dr.IsDBNull(i)) ? DateTime.MinValue : dr.GetDateTime(i); break;
                    case "SoBaiMoiBaiGiang":
                        soBaiMoiBaiGiang = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    case "ThoiDiemTaiLieu":
                        this.thoiDiemTaiLieu = (dr.IsDBNull(i)) ? DateTime.MinValue : dr.GetDateTime(i); break;
                    case "SoBaiMoiTaiLieu":
                        soBaiMoiTaiLieu = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    case "ThoiDiemBaiTap":
                        this.thoiDiemBaiTap = (dr.IsDBNull(i)) ? DateTime.MinValue : dr.GetDateTime(i); break;
                    case "SoBaiMoiBaiTap":
                        soBaiMoiBaiTap = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    case "ThoiDiemDienDan":
                        this.thoiDiemDienDan = (dr.IsDBNull(i)) ? DateTime.MinValue : dr.GetDateTime(i); break;
                    case "SoBaiMoiDienDan":
                        soBaiMoiDienDan = (dr.IsDBNull(i)) ? 0 : dr.GetInt32(i); break;
                    default:
                        break;
                }
            }
        }
    }
}